package com.josn.weatherservicebackend.service;

import cn.hutool.http.HttpUtil;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class GaodeApiRequest {
    /**
     * 获取该地址在高德的信息
     * @param key 密钥
     * @param address 地址
     * @return 该地址在高德中的所有信息
     */
    public String getadcodeByaddress(String key,String address){
        HashMap<String, Object> param = new HashMap<>();
        param.put("key", key);
        param.put("address", address);
        return HttpUtil.get("https://restapi.amap.com/v3/geocode/geo?parameters", param);
    }

    /**
     * 通过Adcode获取该地的天气
     * @param key 密钥
     * @param adcode 该地址的adcode
     * @return
     */
    public String getweatherByadcode(String key,String adcode){
        HashMap<String, Object> param = new HashMap<>();
        param.put("key", key);
        param.put("city", adcode);
        return HttpUtil.get("https://restapi.amap.com//v3/weather/weatherInfo",param);
    }

}
